package com.xu.modules.controller;

import com.xu.common.domain.MyResult;
import com.xu.modules.service.PersonalUserService;
import com.xu.modules.service.bo.LoginBo;
import com.xu.modules.service.bo.PersonalUserRegisterBo;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 个人用户 前端控制器
 * </p>
 *
 * @author xu
 * @since 2022-07-19
 */
@RestController
@RequestMapping("/personalUser")
@RequiredArgsConstructor
public class PersonalUserController {
    private final PersonalUserService personalUserService;


    /**
     * 注册
     */
    @PostMapping("/register")
    public MyResult register(@RequestBody @Valid PersonalUserRegisterBo personalUserRegisterBo){
        return MyResult.ok(personalUserService.register(personalUserRegisterBo));
    }

    /**
     * 登录
     */
    @PostMapping("/login")
    public MyResult login(@RequestBody @Valid LoginBo loginBo){
        return MyResult.ok(personalUserService.login(loginBo));
    }

    /**
     * 获取用户信息
     */
    @GetMapping("/getUserInfo")
    public MyResult getUserInfo(){
        return MyResult.ok(personalUserService.getUserInfo());
    }
}
